<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>       
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>我的工作台</title>
<%@ include file="/WEB-INF/jsp/common/inc.jsp" %>
<script type="text/javascript" src="${_resources}datepicker/WdatePicker.js"></script>

<script  type="text/javascript">
/* var commonProjectList; */
$(function (){
	//项目成员的项目进度监控视图
	commonProjectList = $("#commonProjectList").bootstrapTable({
		url : '${_baseUrl}/projectKt/selectWorkProject?rand='+Math.random(),
		pagination: true,
		pageList: [5, 10, 20, 50],
		queryParams: queryParams,
		clickToSelect: false,
		onLoadSuccess : function(data) {
        	var cellIndex=parseInt($(".table_inline th").length);
            $(".table_inline tr td").each(function(){
                if(this.cellIndex != cellIndex){
                    $(this).attr("title",$(this).text());
                }
            });
  		},
        columns: [{
            title: '序号',
            width: 45,
            formatter: function(value, row, index){
            	return index+1;
            }
         },{
            field: 'projectId',
            title: 'projectId',
            visible:false,
            width: 5
	     },{
        	 field : 'softwareName',
         	 title : '被测软件名称',
             width: 150,
             formatter: function(value, row, index){
            	 if(row.projectStatus == '1'){
            		 //弹出设置项目详细信息页面
            		 if(value == "" || value == null){
            			 return "-"; 
            		 }else{
            		    return "<a title="+value+" href='javascript:void(0)' onclick=\"gotoProjectBaseInfoView('"+row.projectId+"')\">"+value+"</a>";
            		  }
            	 }else{
            		 //跳转到项目测试过程管理进程页面
            		 if(value == "" || value == null){
            			 return "-"; 
            		 }else{
	            		 return "<a title="+value+" href='javascript:void(0)' onclick=\"gotoProjectTestProcess('"+row.projectId+"')\">"+value+"</a>";

            		 }
            	 }	          
             }
         },{
	          field: 'projectPath',
	          title: '项目路径',
	          width: 150
	      },{
        	 field : 'projectStatus',
         	 title : '项目状态',
             width: 65,
             formatter: function(value, row, index){
            	 if(value=='1'){
            		 return "<span class='notCompiled'>待构建</span>";
            	 }else if(value=='2'){
            		 return "<span class='compilation'>进行中</span>";
            	 }else if(value=='3' || value=='4'){
            		 return "<span class='compilation'>暂停中</span>";
            	 }else if(value=='5'){
            		 return "<span class='alreadyPublished'>已归档</span>";
            	 }           	
             }
	     },{
        	 field : 'currentStage',
         	 title : '当前节点id',
         	 visible:false,
             width: 5	            
         },{
        	 field : 'currentStageName',
         	 title : '当前节点',
             width: 65,
             formatter: function(value, row, index){
            	 if(row.projectStatus=='1'){
            		 return "项目定义";
            	 }else{
            		 return value;
            	 }    	
             }
         },{
	         field : 'projectType',
	         title : '项目类型id',
	         width: 100,
	         visible: false
		 },{
        	 field : 'projectTypeName',
         	 title : '项目类型',
             width: 80
	      },{
        	 field : 'projectManagerName',
         	 title : '项目<br/>负责人',
             width: 60
          },{
	          field : 'enterprise',
	          title : '研制单位',
	          width: 100
		  },{
		      field : 'projectStartTime',
		      title : '项目计划<br/>开始日期',
		      width:80
		  },{
        	  field : 'projectEndTime',
         	  title : '项目计划<br/>结束日期',
              width: 80
	      },{
        	 field : 'details',
         	 title : '项目进展详情',
             width: 95,
             formatter: function(value, row, index){
            	 if(row.projectStatus == '1'){
            		 return "-";
            	 }else{
	             	 return "<a href='javascript:void(0)' onclick=\"gotoProjectTestProcess('"+row.projectId+"')\">查看</a>";
            	 }	             	 
             }
	         }],
        onLoadSuccess : function(data) {
        	var cellIndex=parseInt($(".table_inline th").length);
            $(".table_inline tr td").each(function(){
                if(this.cellIndex != cellIndex){
                    $(this).attr("title",$(this).text());
                }
            });
  		},
    });
	
	function queryParams(params){
		return {
		    pageSize: params.limit,
		    pageNo: params.pn,
		    sort : params.sort,
		    order : params.order,
		    pageType : "workbench",
		    softwareName : $("#softwareName").val() == "请输入" ? null : $("#softwareName").val(),
			projectStatus : $("#projectStatus option:selected").val() == '' ? '0' : $("#projectStatus option:selected").val(),
			projectType : $("#projectType option:selected").val() == '' ? null : $("#projectType option:selected").val(),
			projectManager : $("#projectManager option:selected").val() == '' ? null : $("#projectManager option:selected").val(),
			enterprise : $("#enterprise option:selected").val() == '' ? null : $("#enterprise option:selected").val(),
		    projectStartTime : $("#projectStartTime").val() == '' ? null : $("#projectStartTime").val(),
		    projectEndTime : $("#projectEndTime").val() == '' ? null : $("#projectEndTime").val(),
		    flage:"true"
	   }
	}
	/* if("${customCode}"== '712'){
		 $('#commonProjectList').bootstrapTable('hideColumn', 'details');
	}  */
})
var layerIndex = "";
function gotoProjectBaseInfoView(projectId){
		//var path = "${_baseUrl}/projectView/showProjectBaseinfoView?projectId="+projectId;
		window.open("${_baseUrl}/projectView/showProjectBaseinfoView?projectId="+projectId);
		/* layerIndex = layer.open({
			 type: 2,
			 title:'项目详细信息',
			 area: ['700px', '400px'],
			 fixed: false, //不固定
			 maxmin: true,
			 shim: true,
			 content: path,
			 success: function(){
				
			 },
			 moveEnd: function(layero){
				 
			 },
			 cancel: function(){ 
				 layer.closeAll();
			}
		}); */
		layer.full(layerIndex);
	}
	
function gotoProjectBaseInfoView(projectId){
	var path = "${_baseUrl}/projectView/showProjectBaseinfoView?projectId="+projectId+"&rand="+Math.random();
	layerIndex = layer.open({
		 type: 2,
		 title:'设置项目详细信息',
		 area: ['700px', '400px'],
		 fixed: false, //不固定
		 maxmin: true,
		 shim: true,
		 content: path,
		 success: function(){
			
		 },
		 moveEnd: function(layero){
			 
		 },
		 cancel: function(){ 
			 layer.closeAll();
		}
	});
	layer.full(layerIndex);
}


function gotoProjectTestProcess(projectId){
    location.href='${_baseUrl}/projectKt/singleProjectDefinitionTree?projectId='+projectId+'&menuId=${menuId}'+'&rand='+Math.random();
}
	
	
function gotoProjectBaseInfoDetail(projectId){
	window.open("${_baseUrl}/projectKt/showProjectBasinfoForMyWorkbench?projectId="+projectId);
}

//跳转到项目测试过程管理进程
function gotoProjectTestProcess(projectId){
    parent.parent.parent.skipModule1("测试管理","${_baseUrl}/jurisdiction/menuList",'',"d42f113426d7436ba1683856cc1697a1",projectId,"","");
}

function refreshTable(){
	commonProjectList.bootstrapTable('refresh');
}
	
/* 关闭弹出框 */
function closeWin(){
	layer.closeAll();
}
function closeWin1(layerIndex){
	layer.close(layerIndex);
}
document.onkeydown=function(event) 
{ 
	e = event ? event :(window.event ? window.event : null); 
	if(e.keyCode==13){ 
		refreshTable(); 
	} 
} 

</script>
</head>
<style type="text/css">

</style>
<body>
<div class="main">
    <div>
    	<div class="advanced_search">
    		<div class="advanced_search_div"></div>
             <input type="text" name="user_date" id="softwareName" value="" placeholder="请输入被测软件名称" />
              <a class="magnifier" id="search" href="javascript:;"  onclick="refreshTable()"></a>
           <!--   <a class="advanced_search_btn" id="" href="javascript:;" onclick="showme()">更多搜索</a> -->
        </div>
      <%--  <div id="switch" class="switch" style="display:none;width:98%;margin:auto">
	        	<div class="func_time">
	                <input id="projectStartTime" type="text" onchange="refreshTable()" readonly placeholder="计划开始日期" onfocus="WdatePicker({startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})">
	                <a href="javascript:;" class="func_time_a"></a>
	            </div>
	            <div class="func_time">
	                <input id="projectEndTime" type="text" onchange="refreshTable()" readonly placeholder="计划结束日期" onfocus="WdatePicker({startDate:'%y-%M-01',dateFmt:'yyyy-MM-dd',alwaysUseStartDate:true})">
	                <a href="javascript:;" class="func_time_b"></a>
	            </div>
	            <select id="projectStatus" onchange="refreshTable()" class="func_select">
                <option value=''>项目状态</option>	
				<option value="1">待构建</option>
				<option value="2">进行中</option>
				<option value="3">暂停中</option>
				<option value="5">已归档</option>
	            </select>
	            <select id="projectType" onchange="refreshTable()" class="func_select">
	                <option value=''>项目类型</option>
	                <c:forEach var="projectType" items="${projectTypes }" varStatus="status">
	                <option value='${projectType.id}'>${projectType.name}</option>
	                </c:forEach>
	            </select>
	            <select id="projectManager" onchange="refreshTable()" class="func_select">
	                <option value=''>项目负责人</option>
	                <c:forEach var="manager" items="${mangers}">
	                <option value='${manager.id }'>${manager.userName }</option>
	                </c:forEach>
	            </select>
	            <select id="enterprise" onchange="refreshTable()" class="func_select">
	                <option value=''>研制单位</option>
	                <c:forEach var="enterprise" items="${enterprises }">
	                <option value='${enterprise }'>${enterprise }</option>
	                </c:forEach>
	            </select>
	        </div>
    </div> --%>
    <div style="overflow: auto; width:98%;margin: auto;">
	     <table class="table table-bordered table_inline" id="commonProjectList"></table>           
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $("#todo").click(function() {
            layer.open({
                type: 2 //Page层类型
                ,area: ['900px', '400px']
                ,title: '我的工作台--待办事项'
                ,shade: 0.6 //遮罩透明度
                ,maxmin: true //允许全屏最小化
                ,anim: false //0-6的动画形式，-1不开启
                ,content: '${_baseUrl}/workbench/showNeedHandleEvent'
            });
        });
    })
    
    $(function(){
        $("#pending_items").click(function() {
            layer.open({
                type: 2 //Page层类型
                ,area: ['900px', '400px']
                ,title: '我的工作台--待阅事项'
                ,shade: 0.6 //遮罩透明度
                ,maxmin: true //允许全屏最小化
                ,anim: false //0-6的动画形式，-1不开启
                ,content: '${_baseUrl}/workbench/showNeedReadEvent'
            });
        });
    }) 
    
        //ie10以下placeholder兼容样式
    $(function () {
        //浏览器不支持 placeholder 时才执行
        if (!('placeholder' in document.createElement('input'))) {
            $('[placeholder]').each(function () {
                var $tag = $(this); //当前 input
                var $copy = $tag.clone();   //当前 input 的复制
                if ($copy.val() == "") {
                    $copy.css("color", "#999");
                    $copy.val($copy.attr('placeholder'));
                }
                $copy.focus(function () {
                    if (this.value == $copy.attr('placeholder')) {
                        this.value = '';
                        this.style.color = '#000';
                    }
                });
                $copy.blur(function () {
                    if (this.value=="") {
                        this.value = $copy.attr('placeholder');
                        $tag.val("");
                        this.style.color = '#999';
                    } else {
                        $tag.val(this.value);
                    }
                });
                $tag.hide().after($copy.show());    //当前 input 隐藏 ，具有 placeholder 功能js的input显示
            });
        }
    });
    
    $(".advanced_search_btn").click(function(){
    	$(".advanced_search_btn").toggleClass("stop");
    	if($(".advanced_search_btn").hasClass("stop")){
    	  $('.switch').css("display","block");
    	}else{
    	  $('.switch').css("display","none");
    	}
    });
    
    $(".func_time_a").click(function(){
    	$("#projectStartTime").focus();
    	});
    $(".func_time_b").click(function(){
    	$("#projectEndTime").focus();
    	});
</script>
</body>
</html>